<?xml version="1.0" encoding="UTF-8"?>
<html>
    <head>
        <link type="text/css" rel="stylesheet" href="./css/template.css" />
        <link type="text/css" rel="stylesheet" href="./css/SyntaxHighlighter.css" />
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <title>Introduction to Eclipse RCP</title>
        <script language="javascript" src="./js/shInit.js" />
        <script language="javascript" src="./js/shCore.js" />
        <script language="javascript" src="./js/shBrushCpp.js" />
        <script language="javascript" src="./js/shBrushCSharp.js" />
        <script language="javascript" src="./js/shBrushCss.js" />
        <script language="javascript" src="./js/shBrushDelphi.js" />
        <script language="javascript" src="./js/shBrushJava.js" />
        <script language="javascript" src="./js/shBrushJScript.js" />
        <script language="javascript" src="./js/shBrushPhp.js" />
        <script language="javascript" src="./js/shBrushPython.js" />
        <script language="javascript" src="./js/shBrushRuby.js" />
        <script language="javascript" src="./js/shBrushSql.js" />
        <script language="javascript" src="./js/shBrushVb.js" />
        <script language="javascript" src="./js/shBrushXml.js" />
        <keywords>sun,java,eclipse,3.3,rcp,rich,client,platform</keywords>
        <author>Sebastien LAOUT</author>
    </head>
    <body>
        <div class="chapter">
            <h2>Introduction</h2>
            <p>For a long time in computer science, two application models distinguish themselves : heavy applications riches and light clients. Heavy applications run directly on the user's computer, whereas light client are just simply Telnet terminals, AS400, or simply Web browsers. They haven't got any business logic : they just connect to a server which will supply applications and data.</p>
            <p>In the latest years, in the companies, heavy application development has been replaced by Ajax applications. Why? Mainly thanks to almost non-existent deployment of this type of applications. They are stored on a server and the employees can always access the last version thanks to a simple URL address in a browser, installed by default on all computers.</p>
            <p>Although it is interesting for many people, Ajax technology raises several problems, the most important is a long development time. Indeed, the applications must be developed in JavaScript, a non-compiled language which just raises code error during the execution, and its support in the web browsers is often incomplete and OOP is very boring in it. Then, besides recovering data on the server, the browser needs recovering all the interface and the interpretation of Javascript files quickly makes an Ajax application have an unacceptable loading time.</p>
            <p>That's why RCP, Rich Client Platform, offers a good alternative to Ajax light clients. It's the Java platform used to develop Eclipse. Besides the standard components which are quickly reusable, RCP offers the edge into plugins to your application and permits you to update automatically your plugins without restarting the application. So it cancels all the advantages of Ajax towards heavy applications. Thanks to it, you will be able to develop quickly and easily. Your users will be happy of this return to heavy clients, because they will benefit of a user-friendly interface whereas Ajax applications were trying to look like heavy applications, without success.</p>
            <p>This tutorial will show how to realise such a &ldquo;hybrid client&rdquo;, a heavy client which can be updated thanks to a server. You will learn how to create a RCP project, plugins, a plugin update website, and how to interface all of it.</p>
        </div>
        <div class="chapter">
            <h2>I. RCP application components</h2>
            <p>Here are some important definitions for people who don't know Eclipse yet. This tutorial's goal is not to teach you everything (the documentation is important on the Internet), but just RCP plugins.</p>
            <div class="subChapter">
                <h3>I.1 - Eclipse</h3>
                <p>Rich Client Platform is the development base of Eclipse IDE, that's normal that you develop all your applications and RCP plugings with this IDE. It provides several project examples,  Il fournit de nombreux exemples de projets, from the most simple to the most complicated, and a good integration of RCP development tools.</p>
            </div>
            <div class="subChapter">
                <h3>I.2 - SWT</h3>
                <p>All the graphical interface of RCP projects is created with SWT, Standard Widget Toolkit. This toolkit provides all the components needed and offers a native integration of the look of each supported operating system.</p>
            </div>
            <div class="subChapter">
                <h3>I.3 - JFaces</h3>
                <p>JFaces is a sublayer of SWT which adds MVC pattern (Model, View, Controller). With SWT, you can store you data in a single place (the Model) and you can have several different views on it (with arrays, lists, most graphically evolved views... by storing data in memory just once).</p>
            </div>
            <div class="subChapter">
                <h3>I.4 - UI WorkBench</h3>
                <p>That's the most important component brought by RCP : the workbench. This is the principal window of your application. It contains the menu bar, the tools bar, the separation of the window in different redimensionnable and detachable views (with the possibility of displaying it in tabs), the text editors with syntaxic coloration, the XML files edition forms, the lateral panels, the status bar...</p>
                <p>To see what the Workbench supplies, I advice you to open Eclipse : all what is in the principal window is provided by RCP as quickly reusables components. You can also create several perspectives.</p>
                <p>You can also reuse the icons and standard actions, for example copy and paste.</p>
                <p>Without forgetting the fact that you can create properties dialog boxes with a filtrable tree on the left, a header with an icon and a help panel on the right.</p>
            </div>
            <div class="subChapter">
                <h3>I.5 - The plugins</h3>
                <p>The second asset of RCP is, as I already said, the plugin architechture. Indeed, the principal application itself is a plugin. Plugins can modify all the application, add actions in the menu and in the tool bar, change the boot screen... RCP permits the plugins to communicate together, it provides the plugin manager... Thanks to Eclipse, you can create an &ldquo;update website&rdquo; which will content all the plugins and will be on your server so that each client can ask it to know the existence of new plugin versions, to download and install them.</p>
            </div>
        </div>
        <div class="chapter">
            <h2>II. The principal application</h2>
            <p>The aim of this tutorial is to create a simple principal application, and to split each module in independant plugins. The principal application will load the workbech and will make the plugin update. Each plugin must be light to minimize the update downloading time.</p>
            <div class="subChapter">
                <h3>II.1 - Creation of the project</h3>
                <p>Let's create our first RCP application.</p>
                <p>Launch Eclipse and create a new project (File -&gt; New -&gt; Project...). Develop &ldquo;Plug-in Development&rdquo; and select &ldquo;Plug-in Project&rdquo;. As I said, all is plugin in RCP, even the principal application. Click &ldquo;Next &gt;&rdquo;.</p>
                <img src="images/introeclipsercp1.png" />
                <p>Choose a project name, &ldquo;RCPTest&rdquo; for example, then click &ldquo;Next &gt;&rdquo;.</p>
                <p>In the following panel, answer &ldquo;Yes&rdquo; to &ldquo;Would you like to create a rich client application ?&rdquo;. That's here that you specify that your project is a RCP application or a plugin. Click &ldquo;Next &gt;&rdquo;.</p>
                <p>We will use a model for our first RCP application. We will choose &ldquo;RCP Mail Template&rdquo; because it is very complete. Click &ldquo;Finish&rdquo; to create the project.</p>
                <img src="images/introeclipsercp2.png" />
                <p>Eclipse can ask you for opening a new Development Perspective (window displaying, optimized for the development of a special application type) adapted to RCP. If that's the case, click &ldquo;Yes&rdquo;.</p>
                <p>To execute this application, choose &ldquo;Run&rdquo; -&gt; &ldquo;Run As&rdquo; -&gt; &ldquo;Eclipse Application&rdquo;. After a personnalized start panel, you can see this window:</p>
                <img src="images/introeclipsercp3.png" width="100%" />
            </div>
        </div>
        <div class="chapter">
            <h2>III. Plugin implementation</h2>
            <div class="subChapter">
                <h3>III.1 - Creation of a plugin</h3>
                <p>Open the plugin creation assistant thanks to &ldquo;File&rdquo; -&gt; &ldquo;New&rdquo; -&gt; &ldquo;Project...&rdquo;. Choose &ldquo;Plug-in Project&rdquo;, click &ldquo;Next &gt;&rdquo;, give a name to your plugin (&ldquo;RCPPlugin&rdquo; for example), then click &ldquo;Next &gt;&rdquo; twice. We will create a simple simple &ldquo;Hello, World&rdquo; plugin. Choose this model, then click &ldquo;Finish&rdquo;.</p>
                <p>The plugin is, for the moment, independant from the principal application : if you execute the principal application, the  plugin won't be loaded. Choose &ldquo;Run&rdquo; -&gt; &ldquo;Run...&rdquo; to modify the execution options of the principal project. In the &ldquo;Plug-ins&rdquo; tab, check &ldquo;RCPPlugin&rdquo;. This is necessary to execute the plugin with the principal application. Click &ldquo;Run&rdquo;. A new menu (&ldquo;Sample Menu&rdquo;) and a new button in the tool bar appears.</p>
            </div>
            <div class="subChapter">
                <h3>III.2 - Deployment of the application and its plugins</h3>
                <p>We have seen how to create a project and a plugin, and how to execute it in Eclipse.</p>
                <p>To deploy the application on the users' computers, you have to export the RCP project. For that, you have to create a &ldquo;product configuration&rdquo;. You have to make it once, and that will be your project's &ldquo;unique identifier&rdquo;. Indeed, when you export your plugins, you have to associate them an application : those plugins have to be put in Eclipse or in RCPTest. By associating  the product configuration of RCPTest with the plugins, you guarantee that those plugins are integrable in this application.</p>
                <p>The product also permits to change the application name, its icon, its start panel, the start scripts on different platforms, and the plugin to use for the index page.</p>
                <p>Right-click on RCPTest project. Choose &ldquo;New&rdquo; -&gt; &ldquo;Other...&rdquo; -&gt; &ldquo;Plug-in Development&rdquo; -&gt; &ldquo;Product Configuration&rdquo;. Give a name to the file (&ldquo;rcptest.product&rdquo;) and click &ldquo;Finish&rdquo;.</p>
                <p>You're now ready to deploy the application. Right-click on the principal project and choose &ldquo;Export...&rdquo;. Sélectionnez &ldquo;Plug-in Development&rdquo; -&gt; &ldquo;Eclipse Product&rdquo; and click &ldquo;Next &gt;&rdquo;.</p>
                <p>Select a directory where the project will be exported. You can also choose to export it in a ZIP archive. Click &ldquo;Finish&rdquo; and wait for some seconds.</p>
                <p>You can now open the directory where you have exported the application, open the directory &ldquo;eclipse&rdquo; (this name is configurable) to discover this kind of structure :</p>
                <img src="images/introeclipsercp4.png" border="1" />
                <p>That's the same directory structure as Eclipse. Execute &ldquo;eclipse.exe&rdquo; : your application perfectly launches.</p>
                <p>But the plugin isn't in it, that's normal ! We will export and install it, as it would be the deployment of a new plugin, or a new plugin version.</p>
                <p>Right-click the &ldquo;RCPPlugin&rdquo; project, click &ldquo;Export...&rdquo;, but this time, choose &ldquo;Deployable plug-ins and fragments&rdquo;. Click &ldquo;Next &gt;&rdquo;, choose a directory and click &ldquo;Finish&rdquo;.</p>
            </div>
        </div>
        <div class="chapter">
            <h2>IV. Plugins update</h2>
            <div class="subChapter">
                <h3>IV.1 - Update website</h3>
                <p>An update website is just a directory accessible by the network where you can deposit your plugins.</p>
                <p>To create an update website, create a new project and choose &ldquo;Plug-in Development&rdquo; -&gt; &ldquo;Update Site Project&rdquo; :</p>
                <img src="images/introeclipsercp5.png" />
                <p>We will name it &ldquo;RCPUpdate&rdquo;. You can uncheck &ldquo;Use default location&rdquo; and enter the address of a new directory, rather than keeping the default directory: that's in this directory where you will deposit the features and plugins to publish on the website.</p>
                <p>To give your plugins on the update website, you will have to &ldquo;put&rdquo; them in a &ldquo;feature&rdquo;. A feature is just an archive which can content several plugins. For example, the feature &ldquo;Spell checking&rdquo; needs the plugins &ldquo;spellcheck&rdquo;, &ldquo;spellcheck.gui&rdquo;, &ldquo;spellcheck.dic_fr&rdquo;. To help your users, you will group these plugins in a feature.</p>
                <p>We will have to create a feature to give our plugin. Create a new project &ldquo;Plug-in Development&rdquo; -&gt; &ldquo;Feature Project&rdquo; and name it &ldquo;RCPFeature&rdquo;. Click &ldquo;Next &gt;&rdquo; and check &ldquo;RCPPlugin&rdquo; to include the plugin into the feature and click &ldquo;Finish&rdquo;.</p>
                <p>Come back in the edition of the file &ldquo;site.xml&rdquo; from the project &ldquo;RCPUpdate&rdquo;. Click &ldquo;Add Feature...&rdquo;, select &ldquo;RCPFeature&rdquo;, validate with &ldquo;OK&rdquo; and save site.xml with Ctrl+S. Then click &ldquo;Synchronize...&rdquo; and &ldquo;Build All&rdquo; to build the plugin and the feature to give it in the update website. This step is very important, or your website will be empty.</p>
            </div>
            <div class="subChapter">
                <h3>IV.2 - The update manager</h3>
                <p>Now that the update website is ready to use, we will be able to modify our principal application to use this website.</p>
                <p>You just have to inclure the packages org.eclipse.update.* in the project. You will benefit from the entry &ldquo;Software Update&rdquo; in the menu &ldquo;Help&rdquo; of your application, like in Eclipse.</p>
            </div>
        </div>
        <div class="chapter">
            <h2>Conclusion</h2>
            <p>With this tutorial, you would be able to know the RCP application development base. You learnt to create a project, add a plugin, deploy the project and the plugins, and create and use an update website. It's time to play the game.</p>
            <p>With RCP, you are now able to create a modulary enterprise application, where each component will be updated automatically so that the users always benefit from the last version, with a rich, simple and reactive interface.</p>
        </div>
    </body>
</html>

